<extend name="Public:base" />
<block name="content">
    <form method="post" id="validation-form">
    <table class="table table-striped table-bordered table-hover search-form" id="nav-table">
        <thead>
        <th>电子券号：<input name="number" type="text" value="{:I('number')}" />
        电子券名称：<input name="name" type="text"  value="{:I('name')}" />
        用户姓名：<input name="user_name" type="text"  value="{:I('user_name')}" />
        用户电话：<input name="user_phone" type="text"  value="{:I('user_phone')}" />
            <a class="btn btn-primary radius5 btn-sm" href="javascript:;" id="search" url="{:U('Coupon/CouponUseInfo')}">查询</a>
        </thead>
    </table>
    <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover" id="mytable">
            <thead>
            <tr>
                <th class="center" style="width: 46px;">编号</th>
                <th>电子券</th>
                <th class="col-xs-1">电子券类型</th>
                <th class="col-xs-2">会员</th>
                <th class="col-xs-1">领取或使用场景</th>
                <th class="col-xs-1">状态</th>
                <th class="col-xs-1">时间信息</th>
            </tr>
            </thead>
            <tbody>
            <volist name="Coupon" id="vo">
                <tr>
                    <td class="center">{$key+1}</td>
                    <td>电子券号：{$vo.volume_number}<br>
                        名称：{$vo.volume_name}<br>
                        范围：{$vo.category}<br>
                        有效期：{$vo.start_time} - {$vo.end_time}<br>
                        使用条件：订单满{$vo.min}元
                    </td>
                    <td><?php
						switch($vo['type']){
							case '1':
							echo '<span class="yellow bold">代金券</span>';
                            break;
                        case '2':
                        echo '<span class="blue bold">现金券</span>';
                            break;}
                        ?>
                    </td>
                    <td>手机号：<a href="{:U('User/info')}/user_id/{$vo.user_id}">{$vo.phone}</a><br>
                        姓名：{$vo.user_name}
                    </td>
                    <td><php>if($vo['status']!=2){</php>
                            领取：{$vo.get_scene}
                        <php>}else{</php>
                            订单号：<a href="{:U('Order/Normal')}/order_id/{$vo.repair_order_id}">{$vo.repair_order_num}</a><br>分类名：{$vo.category_name}
                        <php>}</php>
                    </td>
                    <td><?php
						switch($vo['status']){
							case '1':
							echo '<span class="yellow bold">未使用</span>';
                            break;
                        case '2':
                        echo '<span class="blue bold">已使用</span>';
                            break;
                        case '2':
                        echo '<span class="blue bold">已过期</span>';
                            break;
                        }
                        ?></td>
                    <td>领取时间：{$vo.add_time}<br>
                        使用时间：{$vo.use_time}
                    </td>
                </tr>
            </volist>
            <tr>
                <td colspan="20" class="page">{$page}</td>
            </tr>
            </tbody>
        </table>
    </div>
    </form>
</block>
<block name="javascript">
    <script>
        $(function(){

            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input,select').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });

            $('#CheckAll').click(function () {
                $("input[name='Del[]']").prop('checked', this.checked);
            })

            $("#submitBtn").click(function(){
                var result = new Array(), str = '';
                $('input[name="Del[]"]:checked').each(function () {
                    result.push($(this).val());
                });
                var str = result.join(',');
                if (str == '') {
                    $.jbox.info('没有选中任何数据！','提示');
                    return false;
                }
                var submit = function (v, h, f) {
                    if (v == 'ok') {
                        $('#validation-form').ajaxSubmit(function(data){
                            if(data=='1'){
                                $.jbox.tip("正在删除数据...", 'loading');
                                // 模拟2秒后完成操作
                                window.setTimeout(function () { $.jbox.tip('删除成功。', 'success');location.reload()}, 1000);
                            }else if(data=='-1'){
                                $.jbox.info("删除失败!",'提示');
                            }else if(data=='2'){
                                $.jbox.info("请先删除子级关系!",'提示');
                            }
                        });
                    }
                    else if (v == 'cancel') {
                        // 取消
                    }

                    return true; //close
                };

                $.jbox.confirm("确定要删除数据吗？", "提示", submit);

                return false;

            });

        });
    </script>
</block>